package com.example.demo.filters.inbound;

import com.netflix.zuul.filters.http.HttpInboundFilter;
import com.netflix.zuul.message.http.HttpRequestMessage;
import rx.Observable;

/**
 * @author sleepforests
 * Created on 2019-06-27
 */
public class IpRateLimitFilter extends HttpInboundFilter {

    // 进入的filter  order值越小越先执行
    @Override
    public int filterOrder() {
        return -2;
    }


    private IpRateLimitService rateLimitService;


    @Override
    public Observable<HttpRequestMessage> applyAsync(HttpRequestMessage input) {
        String originalHost = input.getOriginalHost();


//        return rateLimitService.makeSlowRequest().map(new Function<String, HttpRequestMessage>(){
//
//            @Override
//            public HttpRequestMessage apply(String s) {
//                return null;
//            }
//
//        });

        return null;


    }

    @Override
    public boolean shouldFilter(HttpRequestMessage msg) {
        return true;
    }


}
